package com.itheima.strengthen.test02.controller;

import com.itheima.strengthen.test02.dao.nuoshouDao;
import com.itheima.strengthen.test02.domain.Cask;
import com.itheima.strengthen.test02.domain.NuoZhou;
import com.itheima.strengthen.test02.domain.QSkill;
import com.itheima.strengthen.test02.domain.Skills;
import com.itheima.strengthen.test02.service.nuoshouService;

import java.util.Random;

public class nuoshouController {
//    static nuoshouDao nuoshouDao = new nuoshouDao();
    static nuoshouService nuoshouService = new nuoshouService();
    Random random = new Random();

    public NuoZhou hpAtrributeChange(double hAttack){
        return  nuoshouService.hpAtrributeChange(hAttack);
    }

    public NuoZhou hpAtrributeChange(Skills skills){
        return  nuoshouService.hpAtrributeChange(skills);
    }

    public Skills attack(NuoZhou nuoZhou) {
        while (true){
            //随机抽取三个技能进行攻击
            int choice = random.nextInt(4) + 1;//1-4
            if (choice  == 1){
                int sMp = nuoZhou.getqSkill().getsMp();
                //判断蓝量是否足够
                if (sMp <= nuoZhou.gethMp()){
                    return nuoZhou.getqSkill();
                }else{

                }
            }else if (choice == 2){
                int sMp = nuoZhou.getwSkill().getsMp();
                if(sMp <= nuoZhou.gethMp()){
                    return nuoZhou.getwSkill();
                }else {

                }
            }else if (choice == 3){
                int sMp = nuoZhou.geteSkill().getsMp();
                if(sMp <= nuoZhou.gethMp()){
                    return nuoZhou.geteSkill();
                }else {

                }
            }else {
                return null;
            }
        }
    }

    public NuoZhou mpAttributeChange(Skills skills) {
        return nuoshouService.mpAtrributeChange(skills);
    }

    public void sendAtrribute(NuoZhou nuoZhou) {
        nuoshouService.sendAtrribute(nuoZhou);
    }
}
